import { ref } from 'vue'
import type { Ref } from 'vue'

interface IUserBoolean {
  value: Ref<boolean>;
  setValue: (value?: boolean) => void;
  toggle: () => void;
}

export default function useBoolean (initialValue = false): IUserBoolean {
  const value = ref(initialValue)
  function setValue (toggleValue = false) {
    value.value = toggleValue
  }
  const toggle = () => {
    value.value = !value.value
  }
  return {
    value,
    setValue,
    toggle
  }
}
